package com.example.administrator.appli;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.app.TimePickerDialog;
import android.os.Bundle;
import android.util.Log;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.ToggleButton;

import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;

public class DialogActivity extends Activity {
    int progress = 0;
    String TAG = "DialogActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dialog);


//        AlertDialog.Builder dialog = new AlertDialog.Builder(this);
//        dialog.setTitle("title");
//        dialog.setMessage("message");
//        dialog.setCancelable(false);
//
//        dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
//            @Override
//            public void onClick(DialogInterface dialog, int which) {
//                Toast.makeText(DialogActivity.this, "确定", Toast.LENGTH_LONG).show();
//                dialog.dismiss();
//
//            }
//        });
//        dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
//            @Override
//            public void onClick(DialogInterface dialog, int which) {
//                Toast.makeText(DialogActivity.this, "取消", Toast.LENGTH_LONG).show();
//                dialog.dismiss();
//
//            }
//        });
//        dialog.show();


//        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
//            @Override
//            public void onClick(DialogInterface dialog, int which) {
//                Toast.makeText(DialogActivity.this, "确定", Toast.LENGTH_LONG).show();
//                dialog.dismiss();
//
//            }
//        });
//        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
//            @Override
//            public void onClick(DialogInterface dialog, int which) {
//                Toast.makeText(DialogActivity.this, "取消", Toast.LENGTH_LONG).show();
//                dialog.dismiss();
//
//            }
//        });


//        final ProgressDialog dialog = new ProgressDialog(this);
//        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
//        dialog.setCancelable(true);
//        dialog.setTitle("123");
//        dialog.setMax(100);
//
//        final Timer timer = new Timer();
//        timer.schedule(new TimerTask() {
//            @Override
//            public void run() {
//                progress++;
//                Log.e(TAG, "run: " + progress);
//                dialog.incrementProgressBy(progress);
//                dialog.incrementSecondaryProgressBy(progress);
//                if (progress == 100) {
//                    dialog.dismiss();
//                    timer.cancel();
//                }
//            }
//        }, 0, 200);
//        dialog.show();

//        Calendar cal=Calendar.getInstance();
//        final int hour=cal.get(Calendar.HOUR_OF_DAY);
//        int minute=cal.get(Calendar.MINUTE);
//        TimePickerDialog dialog=new TimePickerDialog(this,R.style.AppTheme_dalog, new TimePickerDialog.OnTimeSetListener() {
//
//            @Override
//            public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
//                Log.e(TAG, "onTimeSet: "+hourOfDay );
//                Log.e(TAG, "onTimeSet: "+minute );
//            }
//        },hour, minute, true);
//        dialog.show();


        Calendar cal = Calendar.getInstance();
        int year = cal.get(Calendar.YEAR);
        int monthOfYear = cal.get(Calendar.MONTH) + 1;
        int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH);
        DatePickerDialog dialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
            @Override
            public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                Log.e(TAG, "onDateSet: " + year);

            }
        }, year, monthOfYear, dayOfMonth);
        dialog.show();


        LinearLayout linearLayout;
        RelativeLayout relativeLayout;
        FrameLayout frameLayout;
        TextView textView;
        ImageButton imageButton;
        ToggleButton toggleButton;
        ImageView imageView;
        EditText editText;
        //继承关系
        TableLayout tableLayout;//继承LinearLayout
    }

}
